package com.example.validation.utils;

import javax.validation.ConstraintValidator;
import javax.validation.ConstraintValidatorContext;

public class EnumValueValidator implements ConstraintValidator<EnumValue, Object> {

	private Class<?> enumValue;

	@Override
	public void initialize(EnumValue constraintAnnotation) {
		this.enumValue = constraintAnnotation.enumValue();
	}

	@Override
	public boolean isValid(Object value, ConstraintValidatorContext context) {
		return EnumUtil.convertEnum(value, enumValue);
	}

	
}
